package com.zx.cloud.controller;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zx.cloud.ApiVersion;
import com.zx.cloud.RequestLogging;
import com.zx.cloud.common.filter.CurrentUserId;
import com.zx.cloud.common.filter.IgnoreAuth;
import com.zx.cloud.domain.ChannelSource;
import com.zx.cloud.domain.User;
import com.zx.cloud.model.response.ObjectDataResponse;
import com.zx.cloud.service.ChannelService;
import com.zx.cloud.service.UserService;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 
 * @ClassName: LoanOrderController
 * @Description: 渠道数据
 * @author: Administrator
 * @date: 2017年10月30日 下午4:18:37
 */
@RestController
@RequestMapping(value = ApiVersion.PROVIDER_V1_PREFIX+"/channel")
public class ChannelController{
	private static final Logger logger=Logger.getLogger(ChannelController.class);
	@Autowired
	private ChannelService channelService;
	
	@Autowired
	private UserService   userService;
	
	@RequestLogging
	@ApiOperation(value = "渠道数据", notes = "渠道数据")
	@RequestMapping(value = "/getChannelList", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<List<ChannelSource>> getChannelList(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long userId,@RequestBody  ChannelSource channelSource){
		
		User  user=userService.get(userId);
		channelSource.setChannelCode(user.getChannelCode());
		List<ChannelSource>  lisSources=channelService.getChannelList(channelSource);
		
		return new ObjectDataResponse<List<ChannelSource>>(lisSources);
	}
}
